#include "threadmanger.h"

MessageClass* ThreadManger::messageclass=nullptr;
DatabaseClass* ThreadManger::databaseclass=nullptr;
SendFileClass* ThreadManger::fileclass=nullptr;
FileLocalClass* ThreadManger::filelocalclass=nullptr;
RecvFileClass* ThreadManger::recvfileclass=nullptr;

QThread* ThreadManger::messagethread=nullptr;
ThreadManger* ThreadManger::threadmanger=nullptr;
QThread* ThreadManger::databasethread=nullptr;
QThread* ThreadManger::filethread=nullptr;
QThread* ThreadManger::filelocalthread=nullptr;
QThread* ThreadManger::recvfilethread=nullptr;


QString  ThreadManger::newUserOC=QString();
ThreadManger* ThreadManger::getInstance()
{
    if(threadmanger==nullptr)
    {
        threadmanger=new ThreadManger();
        messageclass=new MessageClass();
        databaseclass=new DatabaseClass();
        fileclass=new SendFileClass();
        filelocalclass=new FileLocalClass();
        recvfileclass=new RecvFileClass();

        messagethread=new QThread();
        databasethread=new QThread();
        filethread=new QThread();
        filelocalthread=new QThread();
        recvfilethread=new QThread();



        messageclass->moveToThread(messagethread);
        databaseclass->moveToThread(databasethread);
        fileclass->moveToThread(filethread);
        filelocalclass->moveToThread(filelocalthread);
        recvfileclass->moveToThread(recvfilethread);
        //管理类.初始化->消息线程.初始化
        connect(threadmanger,&ThreadManger::s_init,messageclass,&MessageClass::initNetwork);
        //管理类.发送消息->消息线程.发送消息
        connect(threadmanger,&ThreadManger::s_doSend,messageclass,&MessageClass::sendMessage);
        connect(threadmanger,&ThreadManger::s_sendVerify,messageclass,&MessageClass::sendLogin);
        //消息线程.有验证消息->管理类.转发
        connect(messageclass,&MessageClass::s_haveVerify,threadmanger,&ThreadManger::dealVerify);
        //管理类.加载头像->头像库.开始加载头像
        connect(threadmanger,&ThreadManger::s_doLoad,filelocalclass,&FileLocalClass::startLoadAvatar);
        //数据库线程.加载头像完毕->头像库.接收头像
        connect(filelocalclass,&FileLocalClass::s_loadAvatarDone,AvatarLib::getInstance(),&AvatarLib::recvAvatar);
        //管理类.初始化数据库线程->数据库.初始化
        connect(threadmanger,&ThreadManger::s_initMyDatabase,databaseclass,&DatabaseClass::initDatabase);
        //管理类.加载联系人从数据库->数据库线程.加载联系人
        connect(threadmanger,&ThreadManger::s_loadContactDB,databaseclass,&DatabaseClass::loadContactList);
        //数据库线程.加载联系人完毕->联系人库.接收联系人
        connect(databaseclass,&DatabaseClass::s_loadContactDone,ContactLib::getInstance(),&ContactLib::recvContactList);
        //管理类.向新消息库添加记录->新消息库.添加新消息
        connect(threadmanger,&ThreadManger::s_addChat,databaseclass,&DatabaseClass::addChat);
        //新消息库.将新消息写入到数据库->数据库.新消息写入
        connect(ChatBuf::getInstance(),&ChatBuf::s_chatListWrite,databaseclass,&DatabaseClass::writeIntoDB);
        //管理类.刷新->新消息库.刷新，写入
        connect(threadmanger,&ThreadManger::s_refresh,ChatBuf::getInstance(),&ChatBuf::freshNow);
        //管理类.加载上一页->数据库类.加载上一页
        connect(threadmanger,&ThreadManger::s_loadLastPageDB,databaseclass,&DatabaseClass::loadLastPage);
        //管理类.设置历史记录类的OC->数据库.设置历史记录类的OC
        connect(threadmanger,&ThreadManger::s_setHistroyOC,databaseclass,&DatabaseClass::setHistroyOC);
        //数据库类.加载上一页聊天记录完毕->历史记录类.接收历史记录
        connect(databaseclass,&DatabaseClass::s_loadLastPageDone,ChatHistroyLib::getInstance(),&ChatHistroyLib::recvChatHistroyPage);
        //管理类.加载消息列表->数据库类.加载消息列表
        connect(threadmanger,&ThreadManger::s_loadFriendDB,databaseclass,&DatabaseClass::loadFriendList);
        //数据库类.加载消息列表完毕->消息列表库.接收消息列表
        connect(databaseclass,&DatabaseClass::s_loadFriendDone,FriendListLib::getInstance(),&FriendListLib::recvFriendList);
        //聊天记录库.重置->数据库类.重置区间
        connect(threadmanger,&ThreadManger::s_reset,databaseclass,&DatabaseClass::reset);
        //历史记录.重置定时器->数据库线程.重置定时器
        connect(threadmanger,&ThreadManger::s_resetTimer,databaseclass,&DatabaseClass::resetTimer);
        //消息线程.有新消息->数据库线程.出来接收的内容，写入到新消息库并分发
        connect(JSHandler::getInstance(),&JSHandler::s_haveNewMessage,databaseclass,&DatabaseClass::dealRcvContent);
        //数据库.有新消息->管理类转发
        connect(JSHandler::getInstance(),&JSHandler::s_haveNewMessage,threadmanger,&ThreadManger::sendNewMessageToUi);
        //管理类.刷新最新消息的数据库->数据库.刷新最新消息
        connect(threadmanger,&ThreadManger::s_refreshLastestDB,databaseclass,&DatabaseClass::refreshLastest);
        //管理类.删除联系人->数据库线程.删除联系人从数据库
        connect(threadmanger,&ThreadManger::s_deleteContactDB,databaseclass,&DatabaseClass::deleteContact);
        //管理类.保存发送的文件->数据库线程.保存发送的文件
        connect(threadmanger,&ThreadManger::s_addSendFile,filelocalclass,&FileLocalClass::addSendFile);
        //管理类.初始化发送文件线程->发送文件线程.初始化
        connect(threadmanger,&ThreadManger::s_initFileTransmisson,fileclass,&SendFileClass::initSendFileClass);
        //管理类.添加任务到任务队列->发送文件任务队列.添加任务
        connect(threadmanger,&ThreadManger::s_addFileTask,SendQueue::getInstance(),&SendQueue::addFile);
        //发送文件队列.有新任务/还存在未完成任务->发送文件线程.获取任务
        connect(SendQueue::getInstance(),&SendQueue::s_haveNewTask,fileclass,&SendFileClass::getTask);
        //发送文件线程.发送文件完毕->发送文件任务队列.检查是否还有任务
        connect(fileclass,&SendFileClass::s_sendDone,SendQueue::getInstance(),&SendQueue::checkQueue);
        //发送文件线程.当前传输速率->管理类.转发
        connect(fileclass,&SendFileClass::s_speed,threadmanger,&ThreadManger::sendSpeed);
        //发送文件线程.开始传输任务->管理类转发开始信号
        connect(fileclass,&SendFileClass::s_startTask,threadmanger,&ThreadManger::sendstartWork);
        //发送文件线程.发送完毕->管理类转发发送完毕信号
        connect(fileclass,&SendFileClass::s_sendDone,threadmanger,&ThreadManger::sendFileDone);
        connect(fileclass,&SendFileClass::s_sendDone,filelocalclass,&FileLocalClass::saveFrontOne);
        connect(threadmanger,&ThreadManger::s_initRecvFile,recvfileclass,&RecvFileClass::initRecvFileClass);
        connect(threadmanger,&ThreadManger::s_addFavorite,databaseclass,&DatabaseClass::addFavorite);
        connect(threadmanger,&ThreadManger::s_loadFavorite,databaseclass,&DatabaseClass::loadFavoriteList);
        connect(databaseclass,&DatabaseClass::s_loadFavoriteDone,FavoriteLib::getInstance(),&FavoriteLib::recvFavorite);
        connect(threadmanger,&ThreadManger::s_saveFavorite,filelocalclass,&FileLocalClass::copyFile);
        connect(threadmanger,&ThreadManger::s_deleteFile,filelocalclass,&FileLocalClass::deleteFile);
        connect(threadmanger,&ThreadManger::s_deleteFavoriteDB,databaseclass,&DatabaseClass::removeFavoriteDB);
        connect(threadmanger,&ThreadManger::s_setUserAvatar,filelocalclass,&FileLocalClass::setUserAvatar);
        connect(threadmanger,&ThreadManger::s_updateUser,databaseclass,&DatabaseClass::updataUserInfo);
        connect(threadmanger,&ThreadManger::s_initSetting,filelocalclass,&FileLocalClass::initSettings);
        connect(threadmanger,&ThreadManger::s_logout,messageclass,&MessageClass::sendLogout);
        connect(threadmanger,&ThreadManger::s_freshUser,filelocalclass,&FileLocalClass::refreshUser);
        connect(threadmanger,&ThreadManger::s_clearLib,filelocalclass,&FileLocalClass::clearAvatar);
        connect(threadmanger,&ThreadManger::s_clearLib,databaseclass,&DatabaseClass::clearLib);
        connect(threadmanger,&ThreadManger::s_sendUserAvatar,messageclass,&MessageClass::sendUserAvatarFile);
        connect(threadmanger,&ThreadManger::s_sendUserNameUpdate,messageclass,&MessageClass::sendUserNameUpdate);
        connect(threadmanger,&ThreadManger::s_sendUserOCUpdate,messageclass,&MessageClass::sendUserOCUpdate);
        connect(threadmanger,&ThreadManger::s_sendSignup,messageclass,&MessageClass::sendSignUp);
        connect(threadmanger,&ThreadManger::s_updateUserOcFile,filelocalclass,&FileLocalClass::updateUserOC);
        connect(threadmanger,&ThreadManger::s_createNewDatabase,databaseclass,&DatabaseClass::createNewDB);
        connect(threadmanger,&ThreadManger::s_createNewUserAvatar,filelocalclass,&FileLocalClass::createNewUserAvatar);
        connect(threadmanger,&ThreadManger::s_addToFriendList,databaseclass,&DatabaseClass::addToFriendList);
        connect(threadmanger,&ThreadManger::s_sendGetUserInfo,messageclass,&MessageClass::sendGetUserInfo);
        connect(threadmanger,&ThreadManger::s_deleteDB,databaseclass,&DatabaseClass::deleteDatabase);
        connect(threadmanger,&ThreadManger::s_setMesCurrentOC,messageclass,&MessageClass::setCurrentOC);
        connect(databaseclass,&DatabaseClass::s_creatDirDone,threadmanger,&ThreadManger::transCreateDirDone);
        connect(threadmanger,&ThreadManger::s_setDBUseroc,databaseclass,&DatabaseClass::setUseroc);
        connect(threadmanger,&ThreadManger::s_initFileLocal,filelocalclass,&FileLocalClass::initFileLocal);
        connect(threadmanger,&ThreadManger::s_sendGetContactList,messageclass,&MessageClass::sendGetConactList);
        connect(threadmanger,&ThreadManger::s_createNewChatHistroyTable,databaseclass,&DatabaseClass::createChatTable);
        connect(threadmanger,&ThreadManger::s_sendSearchFriend,messageclass,&MessageClass::sendSearchFriednInfo);
        connect(threadmanger,&ThreadManger::s_sendFriendApply,messageclass,&MessageClass::sendFriendApply);
        connect(threadmanger,&ThreadManger::s_addContact,databaseclass,&DatabaseClass::addContact);
        connect(threadmanger,&ThreadManger::s_moveAvatarCacheToAvatar,filelocalclass,&FileLocalClass::moveAvatarCacheToAvatar);
        connect(threadmanger,&ThreadManger::s_appendAvatar,filelocalclass,&FileLocalClass::appendAvatar);
        connect(threadmanger,&ThreadManger::s_removeFriendOne,databaseclass,&DatabaseClass::removeFriendOne);
        connect(threadmanger,&ThreadManger::s_removeFriendList,databaseclass,&DatabaseClass::removeFriendList);
        connect(threadmanger,&ThreadManger::s_addFriendApply,databaseclass,&DatabaseClass::addFriendApply);
        connect(threadmanger,&ThreadManger::s_upDataFriendApplyStatus,databaseclass,&DatabaseClass::upDataFriendApplyStatus);
        connect(threadmanger,&ThreadManger::s_updateFriendApply,databaseclass,&DatabaseClass::upDataFriendApply);
        connect(threadmanger,&ThreadManger::s_loadFriendApply,databaseclass,&DatabaseClass::loadFriendApplyList);
        connect(databaseclass,&DatabaseClass::s_loadFriendApplyDone,FriendApplyLib::getInstance(),&FriendApplyLib::recvFrendApplyList);
        connect(FriendApplyLib::getInstance(),&FriendApplyLib::s_loadFriendApplyDone,threadmanger,&ThreadManger::friendApplyDone);
        connect(threadmanger,&ThreadManger::s_sendFriendResult,messageclass,&MessageClass::sendFriendResult);
        connect(threadmanger,&ThreadManger::s_deleteAvatar,filelocalclass,&FileLocalClass::deleteAvatar);
        connect(threadmanger,&ThreadManger::s_dropChatHistroyTable,databaseclass,&DatabaseClass::dropChatHistroyTable);
        connect(threadmanger,&ThreadManger::s_hideChat,databaseclass,&DatabaseClass::hideChat);
        connect(threadmanger,&ThreadManger::s_deleteChat,databaseclass,&DatabaseClass::deleteChat);
        connect(threadmanger,&ThreadManger::s_deleteFriendRowAndLoad,databaseclass,&DatabaseClass::deleteFriendRowAndLoad);
        connect(threadmanger,&ThreadManger::s_deleteDropFriendAndLoad,databaseclass,&DatabaseClass::deleteDropFriendAndLoad);
        connect(threadmanger,&ThreadManger::s_getFriendLastest,databaseclass,&DatabaseClass::getFriendLastest);
        connect(CustomHandler::getInstance(),&CustomHandler::s_recvContactlistDone,ContactLib::getInstance(),&ContactLib::recvContactList);
        connect(CustomHandler::getInstance(),&CustomHandler::s_recvContactlistDone,databaseclass,&DatabaseClass::writeContactIntoDB);
        connect(CustomHandler::getInstance(),&CustomHandler::s_haveFriendApply,FriendApplyLib::getInstance(),&FriendApplyLib::addApply);
        connect(CustomHandler::getInstance(),&CustomHandler::s_haveFriendApply,databaseclass,&DatabaseClass::addFriendApply);
        connect(CustomHandler::getInstance(),&CustomHandler::s_friendApplyAccess,threadmanger,&ThreadManger::doFriendApplyPass);
        connect(JSHandler::getInstance(),&JSHandler::s_fileReady,fileclass,&SendFileClass::sendFileBlock);
        connect(recvfileclass,&RecvFileClass::s_recvNewFile,threadmanger,&ThreadManger::haveNewFile);
        connect(threadmanger,&ThreadManger::s_flushSettings,filelocalclass,&FileLocalClass::flushSettings);
        //开启线程
        messagethread->start();
        databasethread->start();
        filethread->start();
        filelocalthread->start();
        recvfilethread->start();
    }
    return threadmanger;
}

void ThreadManger::sendMessage(QString senderoc,QString targetoc,QString str)
{
    emit s_doSend(senderoc,targetoc,str);
}

void ThreadManger::sendVerify(QString user, QString password)
{
    emit s_sendVerify(user,password);
}

void ThreadManger::dealVerify(QByteArray recv)
{
    emit s_haveVerify(recv);
}

void ThreadManger::initNetwork(QString addr, qint64 port)
{
    emit s_init(addr,port);
}

void ThreadManger::initDatabase()
{
    emit s_initMyDatabase();
}

void ThreadManger::initFileTransmisson()
{
    emit s_initFileTransmisson();
}

void ThreadManger::initSetting()
{
    emit s_initSetting();
}


void ThreadManger::loadAvatarFromFile()
{
    emit s_doLoad();
}

void ThreadManger::initFileLocal(const QString &useroc)
{
    emit s_initFileLocal(useroc);
}


void ThreadManger::loadLastPage()
{
    emit s_loadLastPageDB();
}

void ThreadManger::loadFriendListDB()
{
    emit s_loadFriendDB();
}

void ThreadManger::loadContactListDB()
{
    emit s_loadContactDB();
}

void ThreadManger::loadLastest()
{
    emit s_loadLastest();
}

void ThreadManger::loadFavorite()
{
    emit s_loadFavorite();
}


void ThreadManger::addChat(QString mettingoc,QString content,bool sender)
{
    emit s_addChat(mettingoc,content,sender);
}


//新消息立即写入数据库，加载聊天记录的区间重置，即从尾加载
void ThreadManger::refreshCurMeeting(QString oc)
{
    //重置历史记录的oc
    emit s_setHistroyOC(oc);
    emit s_refresh();
    emit s_reset();
    emit s_resetTimer();
}

void ThreadManger::refreshLastestDB(QSet<QString> set)
{
    emit s_refreshLastestDB(set);
}

void ThreadManger::writeChatBufNow()
{
    emit s_refresh();
    emit s_resetTimer();
}

void ThreadManger::destroyThreadManger()
{
    emit s_deleteDB();
    messagethread->quit();
    messagethread->wait();
    databasethread->quit();
    databasethread->wait();
    filethread->quit();
    filethread->wait();
    recvfilethread->quit();
    recvfilethread->wait();

}

void ThreadManger::deleteContactDB(QString oc)
{
    emit s_deleteContactDB(oc);
}

void ThreadManger::addSaveFile(QPair<QString,QString> item)
{
    emit s_addSendFile(item);
}

void ThreadManger::addFileTask(QString senderoc, QString receiveroc, QString filepath)
{
    emit s_addFileTask(senderoc,receiveroc,filepath);
}

void ThreadManger::initRecvFile(const QString& useroc)
{
    emit s_initRecvFile(useroc);
}

void ThreadManger::addFavorite(QString senderoc, QString content, QString datetime)
{
    emit s_addFavorite(senderoc,content,datetime);
}

void ThreadManger::saveFavorite(QPair<QString, QString> item)
{
    emit s_saveFavorite(item);
}

void ThreadManger::deleteFile(QString filepath)
{
    emit s_deleteFile(filepath);
}

void ThreadManger::deleteFavoriteDB(QString filename)
{
    emit s_deleteFavoriteDB(filename);
}

void ThreadManger::setUserAvatar(QString path)
{
    emit s_setUserAvatar(path);
}

void ThreadManger::refreshAvatar()
{
    emit s_freshUser();
}

void ThreadManger::updateUser(QString oldoc, QString oc, QString name)
{
    emit s_updateUser(oldoc,oc,name);
}

void ThreadManger::updateUserOcFile()
{
    if(newUserOC.isEmpty())
        return;
    emit s_updateUserOcFile(newUserOC);
}


void ThreadManger::logout(QString oc)
{
    emit s_logout(oc);
}

void ThreadManger::clearLib()
{
    emit s_clearLib();
}

void ThreadManger::sendUserAvatar(QString useroc,QString path)
{
    emit s_sendUserAvatar(useroc,path);
}

void ThreadManger::sendUserNameUpdate(QString useroc, QString newname)
{
    emit s_sendUserNameUpdate(useroc,newname);
}

void ThreadManger::sendUserOCUpdate(QString newuseroc)
{
    emit s_sendUserOCUpdate(newuseroc);
}

void ThreadManger::sendSignup(QString useroc, QString username,QString password,QString avatar)
{
    emit s_sendSignup(useroc,username,password,avatar);
}

void ThreadManger::createNewDatabase(QString username)
{
    emit s_createNewDatabase(username);
}

void ThreadManger::haveSignupRes(QString res)
{
    emit s_haveSignupRes(res);
}

void ThreadManger::createNewUserAvatar()
{
    emit s_createNewUserAvatar();
}

/*void ThreadManger::createNewUserAvatar(QString useroc, QString avatarpath)
{
    emit s_createNewUserAvatar(useroc,avatarpath);
}*/

void ThreadManger::addToFriendList(const QString &oc, const QString &name, const QString &lastest)
{
    emit s_addToFriendList(oc,name,lastest);
}

void ThreadManger::sendGetUserInfo(const QString &useroc)
{
    emit s_sendGetUserInfo(useroc);
}


void ThreadManger::setNewUserOC(QString useroc)
{
    newUserOC=useroc;
}

QString ThreadManger::getNewUserOC()
{
    return newUserOC;
}

void ThreadManger::setMesCurrentOC(const QString &useroc)
{
    emit s_setMesCurrentOC(useroc);
}

void ThreadManger::transUserinfo(const QString &username)
{
    emit s_getUserName(username);
}

void ThreadManger::transCreateDirDone()
{
    emit s_transCreateDirDone();
}

void ThreadManger::setDBUseroc(const QString &useroc)
{
    emit s_setDBUseroc(useroc);
}

void ThreadManger::deleteDatabase()
{
    emit s_deleteDB();
}

void ThreadManger::sendGetContactList()
{
    emit s_sendGetContactList();
}

void ThreadManger::createNewChatHistroyTable(const QString &friendoc)
{
    emit s_createNewChatHistroyTable(friendoc);
}

void ThreadManger::sendSearchFriend(const QString &friendoc)
{
    emit s_sendSearchFriend(friendoc);
}

void ThreadManger::recvSearchFriendDone(const QString & name)
{
    emit s_recvSearchFriendDone(name);
}

void ThreadManger::sendFriendApply(const QString &friendoc)
{
    emit s_sendFriendApply(friendoc);
}

void ThreadManger::friendApplyResult(const QString& friendoc,const QString& friendname)
{
    emit s_friendApplyResult(friendoc,friendname);
    emit s_addContact(friendoc,friendname);
    emit s_moveAvatarCacheToAvatar(friendoc);
    emit s_appendAvatar(friendoc,QString("./User/%1/Avatar/%2.png").arg(FriendListLib::getInstance()->getUserOC()).arg(friendoc));
}

void ThreadManger::removeFriendOne(const QString &friendoc)
{
    emit s_removeFriendOne(friendoc);
}

void ThreadManger::removeFriendList(const QStringList &friendoclist)
{
    emit s_removeFriendList(friendoclist);
}

void ThreadManger::addFriendApply(const QString &friendoc, const QString &friendname, const EnumLib::ApplyStatus status)
{
    emit s_addFriendApply(friendoc,friendname,status);
}

void ThreadManger::upDataFriendApplyStatus(const QString friendoc, const EnumLib::ApplyStatus newstatus)
{
    emit s_upDataFriendApplyStatus(friendoc,newstatus);
}

void ThreadManger::loadFriendApply()
{
    emit s_loadFriendApply();
}

void ThreadManger::friendApplyDone()
{
    emit s_friendApplyDone();
}

void ThreadManger::sendFriendResult(const QString &friendoc)
{
    emit s_sendFriendResult(friendoc);
}

void ThreadManger::moveAvatarCacheToAvatar(const QString &friendoc)
{
    emit s_moveAvatarCacheToAvatar(friendoc);
}

void ThreadManger::addContact(const QString &friendoc, const QString &friendname)
{
    emit s_addContact(friendoc,friendname);
}

void ThreadManger::appendAvatar(const QString& useroc,const QString &oc)
{
    emit s_appendAvatar(useroc,oc);
}

void ThreadManger::deleteAvatar(const QString &oc)
{
    emit s_deleteAvatar(oc);
}

void ThreadManger::dropChatHistroyTable(const QString &oc)
{
    emit s_dropChatHistroyTable(oc);
}

void ThreadManger::hideChat(const QString &friendoc)
{
    emit s_hideChat(friendoc);

}

void ThreadManger::deleteChat(const QString &friendoc)
{
    emit s_deleteChat(friendoc);
}

void ThreadManger::deleteFriendRowAndLoad(const QString &friendoc)
{
    emit s_deleteFriendRowAndLoad(friendoc);
}

void ThreadManger::deleteDropFriendAndLoad(const QString &friendoc)
{
    emit s_deleteDropFriendAndLoad(friendoc);
}

void ThreadManger::getFriendLastest(const QString &friendoc)
{
    emit s_getFriendLastest(friendoc);
}

void ThreadManger::doFriendApplyPass(const QString &friendoc, const QString &friendname)
{
    AvatarLib::getInstance()->appendAvatar(FriendListLib::getInstance()->getUserOC(),friendoc);
    emit s_updateFriendApply(friendoc,friendname,EnumLib::ApplyStatus::TARGETAPPROVED);
    emit s_addContact(friendoc,friendname);
    FriendApplyLib::getInstance()->setApply(friendoc,EnumLib::ApplyStatus::TARGETAPPROVED);
    ContactLib::getInstance()->appendContact(friendoc,friendname);
}



void ThreadManger::haveNewFile(const QString &friendoc, const QString &content)
{
    emit s_addChat(friendoc,"*"+content,true);
    emit s_haveNewFile(friendoc,"*"+content);
}

void ThreadManger::flushSettings()
{
    emit s_flushSettings();
}



void ThreadManger::sendSpeed(float value)
{
    emit s_speed(value);
}

void ThreadManger::sendstartWork(QString filename)
{
    emit s_sendStartWork(filename);
}

void ThreadManger::sendFileDone()
{
    emit s_fileDone();
}


void ThreadManger::sendNewMessageToUi(QPair<QString, QString> mes)
{
    emit s_haveNewMessage(mes);
}



